﻿@using SelfMadeMillionaire.Core
@using SelfMadeMillionaire.Core.Enums
@model SelfMadeMillionaire.Web.Infrastructure.ViewModels.Account.SubscriptionInfoViewModel

<div class="modal-dialog">
    <div class="modal-content">
    @using (Html.BeginForm("SubscriptionInfo", "Admin", FormMethod.Post, new {id = "subscription-form", @class = "form-horizontal"}))
    {
	    @Html.ValidationSummary()
        @Html.HiddenFor(m=>m.ID)
	    <div class="newsletter_subscribe_block" style="padding:10px;">

		    <div class="form-group subscribe_option" style="margin:0">
                <h4 class="profile_title" style="padding-left:15px">Current Newsletter Subscriptions:</h4>
		    </div>
            <div class="content_block_title">
                <h5>Self-Made Millionaire</h5>
            
                <div class="title_bottom_arrow">
					    <img src="@Url.Content("~/Content/images/down_arrow.png")" alt="" />
			    </div>
            </div>

		    <div class="form-group" style="padding-left:20px;padding-top:20px">
			    <label  class="col-sm-2 upgrade-control-label subscribe_nname custom_label">@Model.SMMSubscriptionName</label>
			
			    <div class="col-sm-7">
                    <table>
                    @if (Model.SubscriptionLevel < SubscriptionType.Platinum)
				    {
                        <tr><td style="padding-bottom:5px">
					    <button class="btn btn-info paid" 
					            value="@CoreConstants.UPGRADE_TO_PLATINUM_PRODUCT" 
					            title="@Model.ProductList.First(x => x.Id == CoreConstants.UPGRADE_TO_PLATINUM_PRODUCT).ProductName">
						    @Model.ProductList.First(x => x.Id == CoreConstants.UPGRADE_TO_PLATINUM_PRODUCT).CommandName
					    </button>
                            </td></tr>
				    }

				    @if (Model.SubscriptionLevel < SubscriptionType.Gold)
				    {
            <tr><td style="padding-bottom:5px">
					    <button class="btn btn-info paid" 
					            value="@CoreConstants.UPGRADE_TO_GOLD_PRODUCT" 
					            title="@Model.ProductList.First(x => x.Id == CoreConstants.UPGRADE_TO_GOLD_PRODUCT).ProductName">
						    @Model.ProductList.First(x => x.Id == CoreConstants.UPGRADE_TO_GOLD_PRODUCT).CommandName
					    </button>
                </td></tr>
				    }

				    @if (Model.SubscriptionLevel < SubscriptionType.Silver)
				    {
            <tr><td style="padding-bottom:5px">
					    <button class="btn btn-info paid" 
					            value="@CoreConstants.UPGRADE_TO_SILVER_PRODUCT" 
					            title="@Model.ProductList.First(x => x.Id == CoreConstants.UPGRADE_TO_SILVER_PRODUCT).ProductName">
						    @Model.ProductList.First(x => x.Id == CoreConstants.UPGRADE_TO_SILVER_PRODUCT).CommandName</button>
                </td></tr>
				    }

				    @if (Model.SubscriptionLevel < SubscriptionType.Free)
				    {
            <tr><td style="padding-bottom:5px">
					    <button 
						    class="btn btn-info" 
						    value="@CoreConstants.FREE_SUBSCRIPTION" 
						    title="@Model.ProductList.First(x => x.Id == CoreConstants.FREE_SUBSCRIPTION).ProductName">
						    >
						    @Model.ProductList.First(x => x.Id == CoreConstants.FREE_SUBSCRIPTION).CommandName
					    </button>
                </td></tr>
				    }
				    </table>
			    </div>
		    </div>
			
		    <div class="form-group" style="padding-left:20px">
			    <label class="col-sm-2 upgrade-control-label expires_on custom_label">Expires&nbsp;On: <span style="font-weight:normal; padding-left:10px; color:#333333;">@Model.sExpirationDate</span></label>
				
			    <div class="col-sm-7">
				    @if (Model.SubscriptionLevel > SubscriptionType.Free)
				    {
					    <button class="btn btn-info paid" 
					            value="@CoreConstants.RENEW_PRODUCT" 
					            title="@Model.ProductList.First(x => x.Id == CoreConstants.RENEW_PRODUCT).ProductName">
						    @Model.ProductList.First(x => x.Id == CoreConstants.RENEW_PRODUCT).CommandName</button>
				    }
			    </div>
		    </div>
            @*
		    <div class="form-group" style="padding-left:20px">
			    <label class="col-sm-2 upgrade-control-label Status custom_label">Status: <span style="font-weight: normal; padding-left:40px; color:#333333;">@Model.Status</span></label>
			
			    <div class="col-sm-7">
				    @if (Model.IsSMMSubscribe)
				    {
					    <button id="unsubscribeSMM" class="btn btn-info" title="Upgrade Subscription Level for the same Subscription time frame">Unsubscribe</button>
				    }
				    else
				    {
					    <button id="subscribeSMM" class="btn btn-info" title="Upgrade Subscription Level for the same Subscription time frame">Subscribe</button>
				    }

			    </div>
		    </div>	
            *@
	    </div>
	    <!--end newsletter subscribe block-->

        <div class="form-group" id="paidSection">
	
	        <div id="DueBallance" class="balance_block">
		
	        </div>


	        <div class="newsletter_search_btn">
		        <ul style="display: inline; list-style-type: none;">
			        <li style="float: left; margin-right: 5px;" class="checkout">
				        </li>
			        <li style="float: left; margin-right: 5px;">
				        <button id="bCancel" class="btn btn-primary green">Cancel</button></li>
			
			        <li style="float: right; margin-right: 5px;">
				        <a target="_blank" href="@Url.Action("Index", "Terms")" class="btn btn-info money_back_notice_btn">Money back guarantee</a></li>
		        </ul>
	        </div>
        </div>
    
        <div class="modal-footer">
	    <div class="row">
		    <div class="col-sm-12">
			    <div class="pull-right">
				    <a href="#bCancel" class="btn btn-default width80" data-dismiss="modal">Close</a>
			    </div>
		    </div>
	    </div>
        </div>
    }
    </div>
</div>        
<style>
		.button {
			-moz-border-radius: 6px;
			-o-border-radius: 6px;
			-webkit-border-radius: 6px;
			background: #0028a9;
			border-radius: 6px;
			display: inline-block;
			float: left;
			margin-top: 10px;
			
			margin-left: 20px;
		}

		.currentproduct {
			float: left;
			background-color: darkgreen !important;
		}

		.green { background-color: darkgreen !important; }

		.upgrade-control-label {
			text-align: left !important;
			width: 200px;
		}
		
	</style>
    
<script type="text/javascript">

	$(document).ready(function() {
		$("#paidSection").hide();
		$(".hidden-buttons").hide();
	});

	$(function() {

		

		$("input[type='radio'][name='@Html.NameFor(m => m.SubscriptionLevel)']").attr("disabled", !$("#@Html.IdFor(m => m.IsSMM)").is(":checked"));
        

		$(".paid").click(function () {

			$(this).addClass('currentproduct');
			$("button").attr("disabled", true);
			$("#bCancel").attr("disabled", false);

			var form = $("#subscription-form");
			if (form.valid()) {
				$.ajax({
					url: "@Url.Action("BuyProduct", "MailingList")",
					type: "POST",
					data: { id: $("#ID").val(), producttype: $(".currentproduct").val() },
					cache: false,
					success: function (result) {
					    $("#edit-modal-container").modal('hide');

					    refresh();

					    ShowModalMessage(result.message);
					}
				});
			}

			return false;


		});
        
		$("#unsubscribeSMM").click(function() {
			var form = $("#subscription-form");
			if (form.valid()) {

			    if (confirm("Please confirm that you want to unsubscribe")) {
					$.ajax({
						url: "@Url.Action("UnsubscribeSMM", "MailingList")",
						type: "POST",
						data: { id: $("#ID").val() },
						cache: false,
						success: function (result) {
						    $("#edit-modal-container").modal('hide');

						    refresh();

						    ShowModalMessage(result.message);
						}
					});
				}
			}

			return false;
		});


		$("#subscribeMMM").click(function() {
			var form = $("#subscription-form");
			if (form.valid()) {

				if (confirm("Subscribe for 'Maggie’s Money Mountain' subscription?")) {
					$.ajax({
						url: "@Url.Action("SubscribeMMM", "MailingList")",
						type: "POST",
						data: { id: $("#ID").val() },
						cache: false,
						success: function (result) {
						    $("#edit-modal-container").modal('hide');

						    refresh();

						    ShowModalMessage(result.message);
						}
					});
				}
			}

			return false;
		});

		$("#unsubscribeMMM").click(function() {
			var form = $("#subscription-form");
			if (form.valid()) {
			    if (confirm("Please confirm that you want to unsubscribe")) {
					$.ajax({
						url: "@Url.Action("UnsubscribeMMM", "MailingList")",
						type: "POST",
						data: { id: $("#ID").val() },
						cache: false,
						success: function (result) {
						    $("#edit-modal-container").modal('hide');

						    refresh();

						    ShowModalMessage(result.message);
						}
					});
				}
			}

			return false;
		});

		$("#subscribeSMM").click(function () {
			var form = $("#subscription-form");
			if (form.valid()) {
				$.ajax({
					url: "@Url.Action("SubscribeSMMFree", "MailingList")",
					type: "POST",
					data: { id: $("#ID").val() },
					cache: false,
					success: function (result) {
					    $("#edit-modal-container").modal('hide');

					    refresh();

					    ShowModalMessage(result.message);
					}
				});
			}

			return false;
		});


	});
    </script>

